/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dale2507.gates.configurator.ui;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 *
 * @author Dale
 */
abstract class PropertiesPage extends JPanel {
    
    protected final GridBagConstraints c = new GridBagConstraints();
    
    PropertiesPage() {
        this.setLayout(new GridBagLayout());
        this.addWhitespace();
        
        c.weightx = 1;
        c.insets = new Insets(5,5,5,5);
        c.gridx = 0;
        c.gridy = 0;
        c.fill = GridBagConstraints.BOTH;
    }
    
    protected void addLabelComponentPair(String label, JComponent component, String tooltip) {
        JLabel l = new JLabel(label + ": ");
        l.setToolTipText(tooltip);
        this.add(l, c);
        
        c.gridx++;
        component.setToolTipText(tooltip);
        this.add(component, c);
        
        c.gridx--;
        c.gridy++;
    }
    
    private void addWhitespace() {
        c.gridwidth = 2;
        c.gridy = 10000;
        c.weighty = 1;
        this.add(new JPanel(), c);
        c.weighty = 0;
        c.gridwidth = 1;
        c.gridy = 0;
    }
    
    abstract void liveSave();
    abstract String toYaml();
    
}
